In this lecture, I wanted to show you another cool instance in Roblox that allows us to add realistic
clouds into our games.
This kind of instance can be very crucial for those of you who would like to create a dynamic weather
system, and being able to manipulate the clouds in your game can add another layer of immersion.
So to add clouds into the atmosphere of our game, we can go ahead and create a new cloud instance and
make it a child of the terrain.
So let's go ahead and add a new clouds instance inside of here.
And as you can already see, we've got a few clouds set into the atmosphere.
And we only have three properties to manipulate inside of the cloud, which is how much coverage the
cloud should cover the sky with the density of the cloud, and then the color of the cloud.
So the cover simply defines the percentage of sky that should be covered by clouds in your game.
For example, if you set it to a value of one now your entire sky is going to be covered with those
clouds.
And if you set it to zero, you're going to have no coverage of clouds inside of your game.
I'm going to set it to 0.5 for now.
And if you take a real close look at the clouds, you should be able to notice that they're slightly
moving.
There's a little bit of moving effects to your cloud because again, it has just a little bit more immersion.
You can just kind of see them slowly moving around.
Now the density is going to define the intensity of the particles that make up your clouds.
And this basically just controls the transparency of your clouds, where a small density value is going
to result in thin and wispy looking clouds, while a high value is going to result in thicker and darker
kind of stormy looking clouds.
So with this half sky coverage, if I set the density to something like, let's say I were to set it
to 0.1.
As you can see, we barely can't see any clouds.
There's very few clouds in our game.
They're very thin, very wispy.
And even if I max up the coverage to one and I keep the density at 0.1, as you can see, these clouds
are very thin and we can still see the sun coming through it.
And of course, I can decrease this value even more, and even more so if I set it to a value that's
a little bit.
Two small of a value, but you can still see a very thin layer of clouds in our atmosphere.
So let me try that again.
There we go.
There is a very thin but a complete coverage of clouds over our game.
And of course, the last property here we have is to manipulate the color of the cloud.
So if you want darker clouds, you can of course make it a darker color.
If you want multicolored clouds for some reason, you can change the color of your clouds as well.
And this color property is also going to be influenced by any of the lighting properties that you have
in your game.
So you always want to make sure that you kind of experiment a bit with the lighting properties and the
color of your clouds, just to make it look the best for whatever your game is going to be.
And we are also able to manipulate the speed and the direction of movement for these clouds.
So let me go ahead and increase the density to let's say 0.75.
And we're going to reduce the coverage to 0.6.
So now we have some nice cloud coverage going on.
Now if I want to be able to manipulate the movement of these clouds, then I can go ahead and go to
my workspace and we can go ahead and change the global wind property.
So for example, let's go ahead and have my clouds blow in the X direction.
And actually we can press these three dots right here to open up this menu.
And let's go ahead and increase the speed.
Let me go ahead and move this of the wind.
So if I increase this and increase this, as you can see now our clouds are moving across the sky.
And if I make it extremely fast.
So as you can see, all of our clouds are moving in this particular direction.
But of course I think I'm able to change the yeah, we can change the yaw or I believe this is the pitch.
So right now we're changing the pitch of the wind.
We can change the yaw of the wind.
So this manipulates what direction the clouds are going to be blowing towards.
So now they're moving in that direction.
And if I shift it around now, they're blowing in that direction.
Or if I shift it this way, they're blowing in that direction.
Very cool looking.
Let me go ahead and reset this back to zero.
And let's go ahead and use the tween service to manipulate these clouds in the game from the client
side.
So I'm going to set the cover and density to zero.
And then I'm going to create a local script in starter player scripts.
We're going to go ahead and grab the tween service.
And then we'll make a reference to our clouds instance, which is going to be in the workspace terrain
dot clouds.
Now, if you have streaming enabled in your workspace, you're probably going to have to use wait for
child to access the cloud instance.
But I'm going to disable streaming enabled so I don't have to do that.
And now what I'm going to do is use the tween service create on this cloud instance.
And we want to go ahead and manipulate the density and the coverage property for our clouds.
So we'll do a tween info dot new of let's say five seconds.
And maybe we want to transition from zero coverage and zero density to complete coverage and full density.
So we can go ahead and set the goal table.
The cover is going to be one.
And then the density is also going to be one.
And then we can go ahead and play this tween on the client.
We'll put a small yield here to allow my player to load into the game.
But if you wanted to create a weather system, what you could do is you could have the server pick what
weather is supposed to happen, and then it could set a value and replicated storage to communicate
to all the players in the game, hey, change it to this weather.
Or you could use a remote event and then the clients would execute code on their copy of the game to
manipulate, for example, the clouds.
So let's say it's a sunny day, and then all of a sudden the server decides, hey, you know, it should
be stormy.
So then the client's like, okay, let me go ahead and boom, put in some cloud coverage, and now you've
got stormy clouds covering your game.
You could also manipulate the brightness in your game and the color of the clouds to make them more
dark.
And then afterwards you could figure out how to make some rain effects with particle emitters coming
on your camera, all that kind of good stuff.
But as you can see, it's very easy to manipulate the clouds using the tween service.
If we want a slower transition, of course we can change this value to maybe something like 15 seconds.
So now if we play in our game, we're going to have a slower transition of these clouds coming in to
cover the sky.
So there we go.
Here's our clouds slowly transitioning in and then boom blocks out the sky.
Complete coverage.
And now we've got a very dark looking atmosphere.
So the cloud instance is very basic in terms of its properties, but it easily allows you to add realistic
looking clouds to your game.
I mean, they look pretty stink and cool.
Not gonna lie, these are as realistic clouds as you're going to get in the Roblox game engine.